package BC111_小乐乐与进制转换;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        ArrayList<Integer> list = new ArrayList<>();

        while (n > 0){
            int add = n % 6;
            list.add(0, add);
            n /= 6;
        }


        for (Integer e : list){
            System.out.print(e);
        }
    }
}
